<%@ include file="/common/taglibs.jsp"%>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevent caching at the proxy server
%>

<head>
    <title><fmt:message key="articulolist.title"/></title>
    <meta name="heading" content="<fmt:message key='articulolist.heading'/>"/>    
</head>

<form:form id="articuloList">

	<fieldset style="width: 300px">
	<legend><fmt:message key="common.filtros.busqueda"/></legend>

		<br/><div>
			<fmt:message key="common.articulo"/><br/>
			<input type="text" id="deArticulo" name="deArticulo" class="text medium"/>								
		</div><br/>	
		<div>
			<fmt:message key="common.codigo"/><br/>
			<input type="text" id="coCodigoArticulo" name="coCodigoArticulo" class="text medium"/>			
		</div><br/>
		<div>
			<fmt:message key="common.categoria"/><br/>
			<select id="coCategoria" name="coCategoria" class="text medium">
				<option value="0"><fmt:message key="label.itemdefault"/></option>
				<c:forEach var="categoria" items="${categorias}" varStatus="status">	
					<option value="${categoria.id}">${categoria.deCategoria}</option>
				</c:forEach>			
			</select>
		</div><br/>
				
		<div>
			<input type="button" onclick="buscarArticulos()" value="<fmt:message key="button.search"/>"/>
		</div>					
		</fieldset><br/><br/>
		
		<table id="articulos" cellpadding="0" class="table" cellspacing="0" style="width: 700px" > 
			<thead> 
				<tr> 
		            <th scope="col"><fmt:message key="common.premio"/></th>
		            <th scope="col"><fmt:message key="common.codigo"/></th>
		            <th scope="col"><fmt:message key="common.categoria"/></th>
		            <th scope="col"><fmt:message key="common.unidad.medida"/></th>
		            <th scope="col"><fmt:message key="common.maneja.tipoarticulo"/>?</th>
		            <th scope="col"><fmt:message key="common.stock.actual"/></th>                        
		            <th scope="col"><fmt:message key="common.stock.disponible"/></th>
		            <th scope="col"><fmt:message key="common.stock.catalogo"/></th>
				</tr>
			</thead>
			
			<tbody id="articulosbody">
				<tr id="pattern" style="display:none;">
					<td> 
						<span id="tableArticulo">Articulo</span>						
					</td>
					<td> 
						<span id="tableCodigo">Codigo</span>						
					</td>			
					<td> 
						<span id="tableCategoria">Categoria</span>						
					</td>	
			
					<td> 
						<span id="tableUnidadMedida">Unidad Medida</span>						
					</td>
					<td>
						<span id="tableManejaStock">Maneja Stock</span>
					</td>
					<td> 
						<span id="tableStockActual">Stock Actual</span>						
					</td>
					<td> 
						<span id="tableStockDisponible">Stock Disponible</span>						
					</td>
					<td> 
						<span id="tableStockCatalogo">Stock Catalogo</span>						
					</td>
				</tr>
				
				<c:forEach var="premio" items="${listapremios}" varStatus="status">	
				<tr  style="display:none;">
					<c:choose>
						  <c:when test="${status.index % 2 == 0}"><tr class="odd" ></c:when>
						  <c:otherwise><tr class="even" ></c:otherwise>
					</c:choose>
		
						
						<td>
						<a href="javascript:void(0)" title="Valor" onClick="Modalbox.hide({beforeHide: function(){
						$('premioid').value = '${premio.id}'
						$('coPremio').value = '${premio.coPremio}'
						,$('articuloNameid').value = '${premio.deArticulo}'
						,$('unidadMedida').value = '${premio.deUnidadMedida}'
						,$('stockActual').value = '${premio.stockActual}'
						,$('stockDisponible').value = '${premio.stockDisponible}'
						,$('coArticulo').value = '${premio.coArticulo}'
						,$('canjesLimite').value = '${premio.vaCanjesLimite}'
						,$('canjesLimiteEspejo').value = '${premio.vaCanjesLimiteEspejo}'
						,$('stManejaStockPuntoCanjeID').value   = '${premio.stManejaStockPuntoCanje}'
						,$('stInstantaneoNormalID').value   = '${premio.stInstantaneoNormal}'
						,$('stManejaStockAlmPrincipalID').value = '${premio.stManejaStockAlmPrincipal}'
						,$('vaStockCatalogoID').value = '${premio.vaStockCatalogo}'
						}})">
		                    ${premio.deArticulo}
		                </a>
						</td>	
						<td>
		                    ${premio.coPremio}
		                </td> 
						<td>
		                    ${premio.deCategoria}
		                </td> 
						<td>
		                    ${premio.deUnidadMedida}
		                </td> 
		                
		                <td><c:choose>
		               		<c:when test="${premio.stManejaStockPuntoCanje == 'Y'}">
		               			<fmt:message key='common.maneja.stock.punto.canje'/>
		               		</c:when>
		               		<c:when test="${premio.stManejaStockAlmPrincipal == 'Y'}">
		               			<fmt:message key='common.maneja.stock.almacen.principal'/>
		               		</c:when>
		               		<c:when test="${premio.stInstantaneoNormal == 'Y'}">
		               			<fmt:message key='common.maneja.premioinstantaneo'/>
		               		</c:when>
		                	</c:choose>
		            	</td>				
		
						<td>
		                    ${premio.stockActual}
		                </td>
						<td>
		                    ${premio.stockDisponible}
		                </td>
		                <td>
	                    	<c:choose>
	                    	<c:when test="${premio.vaStockCatalogo == null}">
	                    		0
	                    	</c:when>
	                    	<c:otherwise>
	                    		${premio.vaStockCatalogo}
	                    	</c:otherwise>
	                    	</c:choose>
		                </td> 		                
						</tr>
		        </c:forEach>				 	
			</tbody>
		</table> 
</form:form>

<script type='text/javascript' src="<c:url value="/dwr/interface/WizardPremioCatalogoService.js"/>"></script>